package ifswitch;

import java.util.Scanner;

public class test8 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入一个整数代表星期");
        int week = sc.nextInt();
        /*用if写的
        if (week >=1 && week <=7){
            if (week >=1 && week <=5){
                System.out.println("工作日");
            }
            else if (week >=6 && week <=7){
                System.out.println("休息日");
            }
        }
        else {
            System.out.println("输入错误！");
        }*/
        //switch
    /*switch (week){
        case 1:
            System.out.println("工作日");
            break;
        case 2:
            System.out.println("工作日");
            break;
        case 3:
            System.out.println("工作日");
            break;
        case 4:
            System.out.println("工作日");
            break;
        case 5:
            System.out.println("工作日");
            break;
        case 6:
            System.out.println("休息日");
            break;
        case 7:
            System.out.println("休息日");
            break;
        default:
            System.out.println("没有这个星期！");
            break;

    }*/
        //运用case穿透 ，简化代码
        //当语句体重复的时候，就用case穿透。
        switch (week){
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
                System.out.println("工作日");
                break;
            case 6:
            case 7:
                System.out.println("休息日");
                break;
            default:
                System.out.println("没有这个星期！");
                break;

        }
    }


    }

